package demo5;

import java.io.ObjectStreamClass;
import java.util.Arrays;
import java.util.Objects;

class Student{
    public String ID;

    public Student(String ID) {
        this.ID = ID;
    }

    @Override
    public String toString() {
        return super.toString();
    }

    @Override
    public boolean equals(Object object) {
        Student tmp = (Student) object;
        if(tmp.ID.equals(this.ID)){
            return true;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(ID);
    }
}
public class Test {
    public static void main(String[] args) {
        Student student1 = new Student("123");
        Student student2 = new Student("123");

        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());

        System.out.println("--------");

        System.out.println(student1 == student2);
        System.out.println(student1.equals(student2));

//        String string1 = new String("123");
//        String string2 = new String("123");
//        System.out.println(string1.equals(string2));
    }
}
